const fetchUser = id => {
	return new Promise(resolve => {
		setTimeout(() => {
			console.log('Fetch: ', id)
			resolve(id)
		}, 1000)
	})
}

const cache = {}
const cacheFetchUser = id => {
	if (cache[id]) {
		return cache[id]
	}
	// 缓存promise
	cache[id] = fetchUser(id)
	// cache[id] = axios()
	return cache[id]
}

cacheFetchUser(3).then(id => console.log(id))
// 多次调用promise拿结果，会直接返回上次结果，不会再走promise内部其他代码
cacheFetchUser(3).then(id => console.log(id))
cacheFetchUser(3).then(id => console.log(id))
// Fetch:  3
// 3
// 3
// 3

